package com.example.arithmeticleetcode.leetcode.dec;

import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.Period;
import java.time.format.DateTimeFormatter;
import java.util.Date;

/**
 * @program: arithmetic-leetcode
 * @description:
 * @author: FangZhen
 * @create: 2020-12-10 09:07
 **/
public class Demo06 {

    public static void main(String[] args) {

    }

    public int daysBetweenDates(String date1, String date2) throws Exception {
        LocalDate localDate1 = LocalDate.parse(date1, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        LocalDate localDate2 = LocalDate.parse(date2, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
        return Math.abs((int) (localDate1.toEpochDay() - localDate2.toEpochDay()));
    }
}
